<template>
  <view class="form-item">
    <text class="form-label">图片</text>
    <UploadFile v-model="images" :maxCount="9" @error="handleError" />
  </view>
</template>

<script setup>
import { ref, watch } from 'vue'
import UploadFile from '@/components/upload/UploadFile.vue'

const props = defineProps({
  modelValue: {
    type: Array,
    default: () => []
  }
})

const emit = defineEmits(['update:modelValue', 'error'])

const images = ref(props.modelValue)

watch(() => props.modelValue, (newVal) => {
  console.log("props.modelValue", newVal)
  images.value = newVal
})

watch(images, (newVal) => {
  emit('update:modelValue', newVal)
})

const handleError = (error) => {
  emit('error', error)
}
</script>